<template>
  <div ref="poster" class="poster">
    <div class="cloth"></div>
    <div class="posterImg">
      <img ref="imgs" src="" alt="">
    </div>
    <div class="flower"></div>
    <div class="tips">长按海报可保存哦！</div>
    <div class="btn">
      <div class="btn_l" @click="onceMore"></div>
      <div class="btn_r" @click="isShare = true"></div>
    </div>
    <div class="popup" v-show="isShare" @click="isShare = false">
      <div class="share"></div>
    </div>
    <div class="footer"></div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      isShare: false
    }
  },
  methods: {
    // 再来一张
    onceMore () {
      this.$router.push('index')
    }
  },
  mounted () {
    this.$refs.imgs.src = this.$route.params.imgUrl || JSON.parse(localStorage.getItem('img'))
    if (this.$route.params.imgUrl) {
      localStorage.setItem('img', JSON.stringify(this.$route.params.imgUrl))
    }
  }
}
</script>

<style lang="less">
.poster {
  padding-top: 1px;
  box-sizing: border-box;
  width: 100%;
  min-height: 100vh;
  background-color: #f9ede1;
  .cloth {
    position: absolute;
    right: 0;
    top: 0;
    width: 260px;
    height: 380px;
    z-index: 9;
    background: url('./../assets/img/fn-cloth.png') no-repeat center/100%;
  }
  .posterImg {
    margin: 120px auto 0;
    width: 490px;
    border: 8px solid #fff;
    img {
      display: block;
      margin: 0;
      border: none;
      width: 100%;
    }
  }
  .flower {
    position: relative;
    width: 171px;
    height: 212px;
    margin: -170px 0 0 50px;
    z-index: 9;
    background: url('./../assets/img/fn-sepr-flower.png') no-repeat center/100%;
  }
  .tips {
    text-align: center;
    margin-top: 20px;
    font-size: 30px;
  }
  .btn {
    position: relative;
    margin: 50px auto 0;
    padding-bottom: 120px;
    width: 500px;
    display: flex;
    z-index: 10;
    justify-content: space-between;
    .btn_l {
      width: 214px;
      height: 77px;
      background: url('./../assets/img/btn-l.png') no-repeat center/100%;
    }
    .btn_r {
      width: 214px;
      height: 77px;
      background: url('./../assets/img/btn-r.png') no-repeat center/100%;
    }
  }
  .popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.5);
    .share {
      position: absolute;
      right: 50px;
      top: 50px;
      width: 500px;
      height: 400px;
      background: url("./../assets/img/fn-up-mask.png") no-repeat center/100%;
    }
  }
  .footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 187px;
    z-index: 9;
    background: url('./../assets/img/fn-b-flower.png') no-repeat center/100%;
  }
}
</style>
